package com.clp.protocol.iec104.iec104.client.state;

import io.netty.util.concurrent.Promise;
import lombok.AccessLevel;
import lombok.Getter;

import java.util.concurrent.ScheduledExecutorService;

/**
 * 抽象主站状态：绑定主站、实现定时任务功能。
 */
public abstract class AbstractMasterState extends AbstractActivatableState implements MasterState {
    @Getter(AccessLevel.PROTECTED)
    private final InMasterStateManager stateManager;

    protected AbstractMasterState(InMasterStateManager stateManager) {
        super(stateManager.getInMaster().getAsyncSupport().scheduledExecutorService());
        this.stateManager = stateManager;
    }

    @Override
    protected  <T> Promise<T> createPromise(Class<T> clazz) {
        return stateManager.createPromise(clazz);
    }

    protected ScheduledExecutorService scheduledExecutorService() {
        return stateManager.scheduledExecutorService();
    }
}
